package com.chixing.day11_exception;

public class ExceptionDemo {
    public static void main(String[] args) {
        try {  //捕获可能出现的异常
            System.out.println("try111");
            Class.forName("com.chixing.day11_exception.MapSum"); // 报异常 new ClassNotFoundException();
            System.out.println("try222");
        } catch (ClassNotFoundException e) {
            //处理异常的代码
            System.out.println("catch222");
            e.printStackTrace();
        }
        System.out.println("okokokokok");


        try {
            ExceptionDemo.class.getField("").get(null);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (NoSuchFieldException e) {
            throw new RuntimeException(e);
        }


    }


    /**
     *
     * @return结束方法
     * 1.return  - finally(方法返回值为10，finally a = 20)
     */
    public static int fun1(){
        int a = 10;
        try {
            Class.forName("com.chixing.day11_exception.ds");
            return a;
        }catch (ClassNotFoundException e){
            return -1;
        }finally {
            a=20;
            System.out.println("finally,a= "+a);
        }
    }
}
